package com.wandian.view.mediator
{

	import com.wandian.controller.CLZNoticeName;
	import com.wandian.data.GameData;
	import com.wandian.view.components.ui.LoadingPanelImpl;
	
	import flash.events.Event;
	
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;

	/**
	 * 加载中介者
	 * @author long
	 */
	public class LoadingMediator extends Mediator
	{
		public static const NAME:String="LoadingMediator";

		public function LoadingMediator(viewComponent:Object=null)
		{
			super(NAME, viewComponent);		
			this.loading.addEventListener(Event.COMPLETE, this.completeLoadingHandler);
		}

		private function completeLoadingHandler(event:Event):void
		{
			this.loading.removeEventListener(Event.COMPLETE, this.completeLoadingHandler);
			this.sendNotification(CLZNoticeName.LOAD_SWF_COMPLETE);
			return;
		} 

		override public function listNotificationInterests():Array
		{
			return [CLZNoticeName.LOAD_SWF_PRO];
		} 

		override public function handleNotification(notification:INotification):void
		{
			switch (notification.getName())
			{
				case CLZNoticeName.LOAD_SWF_PRO:
				{
					trace("");
					this.loading.goto(notification.getBody() as int);
					break;
				}
				default:
				{
					break;
				}
			}
			return;
		} 

		private function get loading():LoadingPanelImpl
		{
			return viewComponent as LoadingPanelImpl;
		} 

	}
}
